import { requestPromise } from 'src/erm/sscrppublic/common/utils/asyncFunctions.js';

import {
    toast,
} from 'nc-lightapp-front';

/**
 * @method query 
 * @return {Object} 出参报文
 */
async function auditDataQuery(data, queryUrl) {
    queryUrl || (data.iscreate = 'Y');  //iscreate filed by songjia
    try {
        const result = await requestPromise({
            url: queryUrl || `/nccloud/ssctp/points/SSCPointsQueryAction.do`,
            data
        });
        return result
    } catch (e) {
        toast({ title: e.message, duration: 5, color: 'danger', })
    }
}

/**
 * 查询要点对应的问题
 * @param {*} data 
 */
async function problemQueryByPoint(data) {
    try {
        const result = await requestPromise({
            loading: false,
            url: `/nccloud/ssctp/points/SSCChangePointsQueryAction.do`,
            data
        });
        return result
    } catch (e) {
        toast({ title: e.message, duration: 5, color: 'danger', })
    }
}

/**
 * 查询问题详情
 * @param {*} data 
 */
async function problemQueryByProblemPk(data) {
    try {
        const result = await requestPromise({
            url: `/nccloud/ssctp/points/SSCProblemAddQueryAction.do`,
            data
        });
        return result
    } catch (e) {
        toast({ title: e.message, duration: 5, color: 'danger', })
    }
}


/**
 * 数据刷新
 * @param {*} data 
 */
async function refresh(data) {
    try {
        const result = await requestPromise({
            url: `/nccloud/ssctp/points/SSCRefreshPointsAction.do`,
            data
        });
        return result
    } catch (e) {
        toast({ title: e.message, duration: 5, color: 'danger', })
    }
}

export default {
    auditDataQuery,
    problemQueryByPoint,
    problemQueryByProblemPk,
    refresh
}